package com.chuangjiangx.member.basic.ddd.domain.model.msg;


import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * @author cj-ch
 * @date 2018/1/31 上午12:05
 */
public enum WXMsg {
    /**
     * 会员注册成功通知
     */
    MBR_REGISTRY("OPENTM201252509","会员注册成功通知"),
    /**
     * 储值卡充值成功通知
     */
    MBR_CARD_RECHARGE("OPENTM200545622","储值卡充值成功通知"),
    /**
     * 储值卡消费通知
     */
    MBR_CARD_CONSUME("OPENTM200543224","储值卡消费通知"),
    /**
     * 储值卡退款通知
     */
    MBR_CARD_REFUND("OPENTM414459782","退款通知"),
    /**
     * 积分变动提醒
     */
    MBR_SCORE_CHANGE("OPENTM207509450","积分变动提醒");

    public final String number;
    public final String title;

    WXMsg(String number, String title) {
        this.number = number;
        this.title = title;
    }

    public static WXMsg ofNumber(String number){
        if(StringUtils.isBlank(number)){
            return null;
        }
        for(WXMsg w : WXMsg.values()){
            if(Objects.equals(w.number,number)){
                return w;
            }
        }
        return null;
    }

    public static WXMsg ofTitle(String title){
        if(StringUtils.isBlank(title)){
            return null;
        }
        for(WXMsg w : WXMsg.values()){
            if(Objects.equals(w.title,title)){
                return w;
            }
        }
        return null;
    }
}
